
@extends('Admin.common.header')

<!-- 1.添加meta csrf_token -->
<meta name="csrf-token" content="{{ csrf_token() }}"> 
<br/><br/><br/><br/>

<!-- 页面标记 -->
<div style="float:left;margin-left:130px;">
	<mark style="font-size:18px;">员工列表</mark>
</div>



<!-- 搜索框 -->
<form action="{{ url('/admin') }}" method='post' >
	<div class="col-lg-6" style="width:35%;float:left;margin-left:200px;" >
		<div class="input-group"  >
			
			{{ csrf_field() }}
			
			<input  type="text" name='keyword' class="form-control" placeholder="输入用户名 手机号 进行查询 ...." value="{{ $request or '' }}" />
			
			<span class="input-group-btn">
				<input class="btn btn-default" type="submit" value="Go!" />
				<a class="btn btn-default" href="{{ url('/admin') }}" />清空条件</a>
			</span>
			
		</div>
	</div>
</form>

<br/><br/><br/>

<!-- 员工表格 -->
<div class="bs-example" data-example-id="hoverable-table" style="width:80%;margin:0 auto;">
    <table class="table table-hover">
		<thead>
			<tr>
			  <th>id</th>
			  <th>账号</th>
			  <th>部门</th>
			  <th>权限</th>
			  <th>性别</th>
			  <th>操作</th>
			  <th>联系方式</th>
			  <th>上次登录时间</th>
			</tr>
		</thead>
		<tbody>
			@forelse($admin as $admin_info)
				<tr>
					<th scope="row">{{ $admin_info->id }}</th>
					<td>{{ $admin_info->name }}</td>
					<td>{{ $admin_info->d_name }}</td>
					<td>{{ $admin_info->adminType }}</td>
					<td>{{ $admin_info->adminSex }}</td>
					
					<!-- 正常 -->
					@if ( $admin_info->status == 1 )
					<td> 
						<a href="{{ asset('/admin/create') }}/{{ $admin_info->id }}" >编辑</a>
						&nbsp; | &nbsp; 
						<a style="cursor:pointer;" data-toggle="modal" data-target=".bs-example-modal-sm" onclick="upStatus({{ $admin_info->id }},2)" >撤职</a>
						
						
					</td>
					@else
						<td style="color:red;"> {{ $admin_info->adminStatus }}</td>
					@endif
					
					<td>{{ $admin_info->phone }}</td>
					<td>{{ $admin_info->lasttime }}</td>
				</tr>
			@empty
				<tr>
					<td scope="row"><h2>暂无数据</h2></td>
				</tr>
			@endforelse
		</tbody>
    </table>
</div>

<!-- 分页 -->
<div style='text-align:center;'>
	{{ $admin->appends(['keyword'=>$request])->links() }}
</div>
<div class="badge" style="width:100%;text-align:center;font-size:18px;margin-bottom:70px;" >
		共{{ $admin->total() }}条数据
</div>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
	<div class="modal-dialog modal-sm" role="document" id='show_info'  style="margin-top:80px;margin-left:35%;color:white;font-size:19px;">
	</div>
</div>


<script src=" {{ asset('./js/jquery-1.8.3.min.js') }} "></script>
<script>
	<!-- 2.设置全局ajax选项 -->
	$.ajaxSetup({
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});
	var _token = $('meta[name="csrf-token"]').attr('content');
	
	// 执行 修改用户状态 为已离职
	function upStatus( id,status )
	{
		if( confirm('你真的确定？') )
		{
			$.ajax({
				type:"post",
				url:"{{ url('/admin/upStatus') }}"+'/'+id,
				data:{status:status,_token:_token},
				async:true,    					
				dataType:"json",
				success:function(back){
					// 2.模态框 不要动
					$('#show_info').html( '' );
					$('#show_info').html( back['show_info'] );
					setTimeout(function(){
						location.reload(); 
					}, 1000);  
					
				}
			});
		}else
		{
			location.reload();
		}
	}
</script>


@extends('Admin.common.footer')